<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Hammerspoon docs: UniversalArchive</title>
    <style type="text/css">
      a { text-decoration: none; }
      a:hover { text-decoration: underline; }
      th { background-color: #DDDDDD; vertical-align: top; padding: 3px; }
      td { width: 100%; background-color: #EEEEEE; vertical-align: top; padding: 3px; }
      table { width: 100% ; border: 1px solid #0; text-align: left; }
      section > table table td { width: 0; }
    </style>
    <link rel="stylesheet" href="docs.css" type="text/css" media="screen" />
  </head>
  <body>
    <header>
      <h1><a href="./index.html">docs</a> &raquo; UniversalArchive</h1>
      <p>Handle "archive current item" for multiple applications using the same hotkey</p>
<p>Download: <a href="https://github.com/Hammerspoon/Spoons/raw/master/Spoons/UniversalArchive.spoon.zip">https://github.com/Hammerspoon/Spoons/raw/master/Spoons/UniversalArchive.spoon.zip</a></p>
<p>Using this Spoon enables you to use a single hotkey to archive an
item in multiple applications.  Out of the box the following
applications are supported: Evernote, Mail, Spark and Outlook. You
can easily register handlers for new applications (or override the
built-in ones) using the <code>registerApplication()</code> method. If you
write a new handler and feel others could benefit from it, please
submit a pull request!</p>
<p>Handlers can also provide support for archiving to multiple
locations, and you can bind different hotkeys for each
destination. At the moment only Evernote supports this. See the
documentation for <code>bindHotkeys()</code> for the details on how to
specify multiple-destination filing hotkeys.</p>

      </header>
      <h3>API Overview</h3>
      <ul>
        <li>Variables - Configurable values</li>
          <ul>
            <li><a href="#archive_notifications">archive_notifications</a></li>
            <li><a href="#evernote_archive_notebook">evernote_archive_notebook</a></li>
            <li><a href="#evernote_delay_before_typing">evernote_delay_before_typing</a></li>
            <li><a href="#logger">logger</a></li>
            <li><a href="#outlook_archive_folder">outlook_archive_folder</a></li>
          </ul>
        <li>Methods - API calls which can only be made on an object returned by a constructor</li>
          <ul>
            <li><a href="#bindHotkeys">bindHotkeys</a></li>
            <li><a href="#evernoteArchive">evernoteArchive</a></li>
            <li><a href="#mailArchive">mailArchive</a></li>
            <li><a href="#outlookArchive">outlookArchive</a></li>
            <li><a href="#registerApplication">registerApplication</a></li>
            <li><a href="#sparkArchive">sparkArchive</a></li>
            <li><a href="#universalArchive">universalArchive</a></li>
          </ul>
      </ul>
      <h3>API Documentation</h3>
        <h4 class="documentation-section">Variables</h4>
          <section id="archive_notifications">
            <a name="//apple_ref/cpp/Variable/archive_notifications" class="dashAnchor"></a>
            <h5><a href="#archive_notifications">archive_notifications</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.archive_notifications</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Boolean indicating whether a notification should be produced when an item is archived. Defaults to "true".</p>
</td>
              </tr>
            </table>
          </section>
          <section id="evernote_archive_notebook">
            <a name="//apple_ref/cpp/Variable/evernote_archive_notebook" class="dashAnchor"></a>
            <h5><a href="#evernote_archive_notebook">evernote_archive_notebook</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.evernote_archive_notebook</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Name of the Notebook to use for archiving in Evernote. Defaults to "Archive"</p>
</td>
              </tr>
            </table>
          </section>
          <section id="evernote_delay_before_typing">
            <a name="//apple_ref/cpp/Variable/evernote_delay_before_typing" class="dashAnchor"></a>
            <h5><a href="#evernote_delay_before_typing">evernote_delay_before_typing</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.evernote_delay_before_typing</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>In Evernote, archive is done by selectin "Move note" and then
simulating typing of the notebook name. A short pause in between
makes it more reliable for Evernote to recognize the notebook name
correctly. This variable controls how much to wait, in seconds.
Do not change this unless you know what you are doing</p>
</td>
              </tr>
            </table>
          </section>
          <section id="logger">
            <a name="//apple_ref/cpp/Variable/logger" class="dashAnchor"></a>
            <h5><a href="#logger">logger</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.logger</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Logger object used within the Spoon. Can be accessed to set the default log level for the messages coming from the Spoon.</p>
</td>
              </tr>
            </table>
          </section>
          <section id="outlook_archive_folder">
            <a name="//apple_ref/cpp/Variable/outlook_archive_folder" class="dashAnchor"></a>
            <h5><a href="#outlook_archive_folder">outlook_archive_folder</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.outlook_archive_folder</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Name of the mailbox to use for archiving in Outlook. You must move a message manually to that mailbox at least once so that it appears in the "Message" -&gt; "Move..." submenu. Defaults to "Archive"</p>
</td>
              </tr>
            </table>
          </section>
        <h4 class="documentation-section">Methods</h4>
          <section id="bindHotkeys">
            <a name="//apple_ref/cpp/Method/bindHotkeys" class="dashAnchor"></a>
            <h5><a href="#bindHotkeys">bindHotkeys</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:bindHotkeys(mapping)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Binds hotkeys for UniversalArchive</p>
<p>Parameters:</p>
<ul>
<li>mapping - A table containing hotkey modifier/key details for the following items:<ul>
<li><code>archive</code> - hotkey for trigger the <code>universalArchive()</code> method, to archive the current item on the current application.</li>
<li><code>&lt;app&gt;_&lt;dest&gt;</code> - if an application handler supports multiple destinations, you can specify hotkeys for specific destinations using this format. For example, to assign a hotkey that files the current note in Evernote to the "MyProject" notebook using Ctrl-Alt-Cmd-M, you would specify <code>Evernote_MyProject = { { "ctrl", "alt", "cmd" }, "m" }</code> as one of the elements of <code>mapping</code>. Keep in mind that the application name must appear exactly as the system sees it (including upper/lowercase), and that if either the application or the destination name contain spaces or other non-alphanumeric characters, you need to use the Lua table notation. For example: <code>["Evernote_Some Long Notebook Name"] = { keybinding }</code>. At the moment only the Evernote handler supports multiple destinations.</li>
</ul>
</li>
</ul>
</td>
              </tr>
            </table>
          </section>
          <section id="evernoteArchive">
            <a name="//apple_ref/cpp/Method/evernoteArchive" class="dashAnchor"></a>
            <h5><a href="#evernoteArchive">evernoteArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:evernoteArchive(where)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Archive current note in Evernote.</p>
<p>Parameters:</p>
<ul>
<li>where - destination notebook. Defaults to the value of <code>UniversalArchive.evernote_archive_notebook</code>.</li>
</ul>
</td>
              </tr>
            </table>
          </section>
          <section id="mailArchive">
            <a name="//apple_ref/cpp/Method/mailArchive" class="dashAnchor"></a>
            <h5><a href="#mailArchive">mailArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:mailArchive()</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Archive current message in Mail using the built-in Archive functionality</p>
<p>Parameters:</p>
<ul>
<li>none</li>
</ul>
</td>
              </tr>
            </table>
          </section>
          <section id="outlookArchive">
            <a name="//apple_ref/cpp/Method/outlookArchive" class="dashAnchor"></a>
            <h5><a href="#outlookArchive">outlookArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:outlookArchive()</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Archive current message in Outlook using one of two methods:</p>
<ol>
<li>If the "Message -&gt; Archive" menu item exists, it is used (this
has been added in recent versions of Outlook)</li>
<li>Otherwise, the message gets manually moved to the folder
specified in <code>UniversalArchive.outlook_archive_folder</code>. The folder
has to appear in the Message -&gt; Move submenu for this to
work. Since this submenu only lists the last few destination
folders, you have to move a message by hand the first time (or
periodically if you don't archive very often).</li>
</ol>
<p>Parameters:</p>
<ul>
<li>none</li>
</ul>
</td>
              </tr>
            </table>
          </section>
          <section id="registerApplication">
            <a name="//apple_ref/cpp/Method/registerApplication" class="dashAnchor"></a>
            <h5><a href="#registerApplication">registerApplication</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:registerApplication(appname, fn)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Register a handler function for an application.</p>
<p>Parameters:</p>
<ul>
<li>appname - string containing the name of the application. If the application already has a handler, it will be replaced with the new one.</li>
<li>fn - handler function (to remove the handler for an application, use <code>nil</code>). The function receives the following arguments:<ul>
<li>self - the UniversalArchive object, so the handler can make use of all the object methods and variables.</li>
<li>where - optional "destination" for the archive operation. Handlers must provide a default destination when <code>where == nil</code>. Destination doesn't make sense for all applications, so the implementation of this is optional and depending on the handler.</li>
</ul>
</li>
</ul>
</td>
              </tr>
            </table>
          </section>
          <section id="sparkArchive">
            <a name="//apple_ref/cpp/Method/sparkArchive" class="dashAnchor"></a>
            <h5><a href="#sparkArchive">sparkArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:sparkArchive()</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Archive current message in Spark using the built-in Archive functionality</p>
<p>Parameters:</p>
<ul>
<li>none</li>
</ul>
</td>
              </tr>
            </table>
          </section>
          <section id="universalArchive">
            <a name="//apple_ref/cpp/Method/universalArchive" class="dashAnchor"></a>
            <h5><a href="#universalArchive">universalArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:universalArchive(where)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Main entry point for archiving an item. If a handler function is
defined for the current application, it is called with the
<code>UniversalArchive</code> object as its first argument, and the archive
destination (if provided) as the second. Handlers must have a
"default destination" that gets used when no destination is
provided. Not all handlers support specifying a destination. New
handlers can be registered using the <code>registerApplication()</code>
method.</p>
</td>
              </tr>
            </table>
          </section>
  </body>
</html>